package com.platform.mobile.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.platform.common.dao.impl.CommonDaoImpl;
import com.platform.mobile.dao.DatasourceDao;
import com.platform.mobile.entity.VisitOrg;
import com.platform.mobile.entity.VisitUser;

@Repository
public class DatasourceDaoImpl extends CommonDaoImpl 
			implements DatasourceDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<VisitOrg> getOrgByParentID(Integer parent_id) {
		
		List<VisitOrg> list = new ArrayList<VisitOrg>();
		List<Object> params = new ArrayList<Object>();
		
		StringBuilder whereSql = new StringBuilder("from VisitOrg where 1=1 ");
		
		whereSql.append("and parent_id = ?");
		params.add(parent_id);
		
		list = (List<VisitOrg>) getListByHQL(whereSql.toString(),params.toArray(),null);
		return list;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<VisitUser> getUserByDeptID(Integer dept_id) {
		
		List<VisitUser> list = new ArrayList<VisitUser>();
		List<Object> params = new ArrayList<Object>();
		
		StringBuilder whereSql = new StringBuilder("from VisitUser where 1=1 ");
		
		whereSql.append("and DEPT_ID = ?");
		params.add(dept_id);
		
		list = (List<VisitUser>) getListByHQL(whereSql.toString(),params.toArray(),null);
		return list;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<VisitOrg> getOrgById(Integer ID) {
		List<VisitOrg> list = new ArrayList<VisitOrg>();
		List<Object> params = new ArrayList<Object>();
		
		StringBuilder whereSql = new StringBuilder("from VisitOrg where 1=1 ");
		
		whereSql.append("and ID = ?");
		params.add(ID);
		
		list = (List<VisitOrg>) getListByHQL(whereSql.toString(),params.toArray(),null);
		return list;
	}

}
